import { createApp } from 'vue'
// iview plus
import ViewUIPlus from 'view-ui-plus'
import 'view-ui-plus/dist/styles/viewuiplus.css'

// 引入vxe-table
// import 'xe-utils'
// import VXETable from 'vxe-table'
// import 'vxe-table/lib/style.css'

// 挂载全局API
import configGlobalAPI from './globalAPI'
import {
    storeInstance,
    routerInstance,
    vueI18nInstance
} from './index'

import "./style/font_icon/iconfont.css";
import "./style/font_system/iconfont.css";
import "./style/index.scss";
import { extendStorage, syncSessionStorage, initEnvPrefix, updateVersion, handleHostname } from './utils/tools';
import { LogoutBase } from "./service/base";
import Cookies from "js-cookie";
import recode from './utils/recode';
//必须先初始化global.SYSID
global.SYSID = JSON.parse(Cookies.get("organization") || '{}').id;
global.DOMAIN = handleHostname('.localhost');

//同步storage
syncSessionStorage();
//初始化环境前缀
initEnvPrefix(process.env.VUE_APP_HOST_PREFIX);
//是否版本更新
updateVersion(LogoutBase);
//扩展storage
extendStorage();

recode();

const i18nStore = vueI18nInstance();

const app = createApp({})
    .use(storeInstance())
    .use(routerInstance())
    .use(i18nStore)
    .use(ViewUIPlus, {
        i18nStore
    })
    // .use(VXETable);

app.mount('#app')
// 去掉生产环境的警告
if (process.env.NODE_ENV === 'production') {
    app.config.warnHandler = (msg,instance,trace)=>{}
}
// 挂载全局API
configGlobalAPI(app)

export default app
